#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QGraphicsScene>
#include <QLabel>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    Ui::MainWindow *ui;

    QLabel *labelItem = NULL;
    QLabel *labelScene = NULL;
    QLabel *labelView = NULL;
    QLabel *labelInfo = NULL;

    int zValue = 0;

    int item_id = 0;

    static const int ITEM_ID = 1;  //图形项存放图形项ID的键值
    static const int ITEM_DESCRIPTION = 2; //图形项存放图形项属性描述的键值

    QGraphicsScene *scene = NULL;

    void initView();

protected slots:

    void on_graphicsView_keyPress(QKeyEvent *event);

    void on_graphicsView_mouseDoubleClick(QPoint point);

    void on_graphicsView_mousePress(QPoint point);

    void on_graphicsView_mouseMove(QPoint point);

    void on_actionRectangle_triggered();
    void on_actionEllipse_triggered();
    void on_actionCircle_triggered();
    void on_actionTriangle_triggered();
    void on_actionTrapezoid_triggered();
    void on_actionLine_triggered();
    void on_actionText_triggered();
    void on_actionMagnify_triggered();
    void on_actionDownsize_triggered();
    void on_actionRestore_triggered();
    void on_actionLeft_triggered();
    void on_actionRight_triggered();
    void on_actionPre_triggered();
    void on_actionRear_triggered();
    void on_actionCombine_triggered();
    void on_actionApart_triggered();
    void on_actionDelete_triggered();
    void on_actionExit_triggered();

    void drawGridBackground(); // 绘制网格

    //符号保存与载入，符号库管理
    void saveSymbols(const QString& fileName);
    void loadSymbols(const QString& fileName);

private slots:
    void on_actionSaveSymbols_triggered();
    void on_actionLoadSymbols_triggered();
    void on_actionSymbolLibrary_triggered();
};
#endif // MAINWINDOW_H
